import pymysql

from mysql_util import MysqlUtil

connectiont = pymysql.connect(
    host = 'localhost', # 主机名
    user = 'root',      # 数据库用户名
    password = '',  # 数据库密码
    db = 'test',      # 数据库名
    charset = 'utf8',   # 字符集编码
    cursorclass = pymysql.cursors.DictCursor # 游标类型
)

print(connectiont)
cursor = connectiont.cursor() # 获取游标对象
# sql = """
# create table user_table(
# id int(8) auto_increment primary key,
# username varchar(30) not null,
# email varchar(30) not null,
# password varchar(30) not null,
# confirm_password varchar(30) not null,
# create_time datetime);
# """

sql = """
create table category(
  `id` varchar(50) NOT NULL,
  `cname` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
"""

db = MysqlUtil()

category = db.insert(sql)
print("ok")
# cursor.execute(sql) # 执行SQL语句
# cursor.close()      # 关闭游标
# connectiont.close() # 关闭连接
